package com.AAL.DAO;

import java.util.List;

import org.hibernate.classic.Session;

import com.AAL.DAO.Interface.IPlanAssessmentReportDAO;
import com.AAL.Model.Employee;
import com.AAL.Model.Plan;
import com.AAL.Model.PlanAssessmentReport;
import com.AAL.Utils.HibernateUtil;

public class PlanAssessmentReportDAO implements IPlanAssessmentReportDAO {

	@Override
	public PlanAssessmentReport saveAndUpdatePlanAssessmentReport(
			PlanAssessmentReport planAssessmentReport) {
		Session session = HibernateUtil.getSessionFactory().getCurrentSession();
		session.beginTransaction();
		try {
			session.saveOrUpdate(planAssessmentReport);
		} catch (Exception e) {
			return null;
		}
		session.getTransaction().commit();
		return planAssessmentReport;
	}

	@Override
	public PlanAssessmentReport deletePlanAssessmentReport(
			int planAssessmentReportID) {
		Session session = HibernateUtil.getSessionFactory().getCurrentSession();
		try {
			session.beginTransaction();
			PlanAssessmentReport planAssessmentReport = (PlanAssessmentReport) session
					.load(PlanAssessmentReport.class, planAssessmentReportID);
			if (null != planAssessmentReport) {
				session.delete(planAssessmentReport);
			}
			session.getTransaction().commit();
			return planAssessmentReport;
		} catch (Exception e) {
			e.printStackTrace();
			session.getTransaction().rollback();
			return null;
		}
	}

	@Override
	public PlanAssessmentReport getPlanAssessmentReport(
			int planAssessmentReportID) {
		Session session = HibernateUtil.getSessionFactory().getCurrentSession();
		session.beginTransaction();
		PlanAssessmentReport planAssessmentReport = (PlanAssessmentReport) session
				.load(PlanAssessmentReport.class, planAssessmentReportID);
		return planAssessmentReport;
	}

	@Override
	public List<PlanAssessmentReport> getLstPlanAssessmentReportsByEmployee(
			Employee employee) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<PlanAssessmentReport> getLstPlanAssessmentReportsByPlan(
			Plan plan) {
		// TODO Auto-generated method stub
		return null;
	}

}
